<% if flash[:error] %>
  <p class="error">
    <%= flash[:error] %>
    <a href="#" class="close-notice"></a>
  </p>
<% end %>
<%= form_for @document, :html => { :multipart => true } do |f| %>
<%= f.hidden_field :category_id %>
<table style="margin: 10px;">
  <tr>
    <td><%= f.label :name, "Nombre" %></td>
    <td><%= f.text_field :name, :style => "width: 420px;", :id => "input01" %></td>
  </tr>
  <tr>
    <td><%= f.label :description, "Descripción" %></td>
    <td><%= f.text_area :description, :style => "height: 50px;width:420px;", :id => "input02" %></td>
  </tr>
  <tr>
    <td><%= f.label :upload_at, "Fecha:" %></td>
    <td><%= f.date_select :upload_at, :id => "input03" %></td>
  </tr>  
  <tr>
    <td><%= f.label :content, "Archivo" %></td>
    <td><%= f.file_field :content %></td>
  </tr>  
</table>  
<% end %>  
<% if (@close) then  %>
  <script type="text/javascript">
    $(function() {
      var categoryId = <%= @category_id %>;
      
      if (categoryId == <%= @agendaPleno.id %>) {
        window.parent.App.PlenoDocumentController.reload({"category": categoryId});
      } else if (categoryId == <%= @agendaPermanente.id %>) {
        window.parent.App.PermanenteDocumentController.reload({"category": categoryId});
      } else if (<% @sesionesOrdinarias.each_with_index do |category,index| %> categoryId == <%= category.id %> <%= category.id != @sesionesOrdinarias.last.id ? '||':'' %> <% end %>) {
        window.parent.App.OrdinariaDocumentController.reload({"category": categoryId});
      } else if (<% @sesionesExtraOrdinarias.each_with_index do |category,index| %> categoryId == <%= category.id %> <%= category.id != @sesionesExtraOrdinarias.last.id ? '||':'' %> <% end %>) {
        window.parent.App.ExtraOrdinariaDocumentController.reload({"category": categoryId});
      } else {
        window.parent.App.DocumentController.reload({"category": categoryId});
      }
      
      window.parent.addDocumentPopup.modal("hide");
    });
  </script>
<% end %>
